@echo off
chcp 437
echo [INFO] Building a simple version of ZabbixTool...

REM 安装依赖
echo [INFO] Installing dependencies...
pip install --only-binary :all: pyinstaller PyQt5 pandas==2.0.3 openpyxl==3.0.9 requests==2.27.1 urllib3==1.26.7

REM 创建或清空logs目录
echo [INFO] Setting up directories...
if not exist logs mkdir logs
if not exist resources mkdir resources
if not exist "resources\config.json" echo {} > "resources\config.json"

REM 直接打包为单个文件，确保添加--add-data选项
echo [INFO] Building executable...
pyinstaller --clean --onefile --console --name ZabbixTool ^
  --add-data "resources;resources" ^
  main.py

echo.
if exist "dist\ZabbixTool.exe" (
    echo [SUCCESS] Build successful! Executable generated in dist directory.
    echo [SUCCESS] Path: %cd%\dist\ZabbixTool.exe
) else (
    echo [ERROR] Build failed. Please check the logs.
)

pause 